package br.nextfm.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Dao {

	private EntityManagerFactory factory;
	private EntityManager manager = createManager();
	
	private EntityManagerFactory createFactory() {
		if(factory == null){
			factory = Persistence.createEntityManagerFactory("NextFm");
		}
		return factory;
	}
	
	private EntityManager createManager() {
		return createFactory().createEntityManager();
	}

	public EntityManagerFactory getFactory() {
		return factory;
	}

	public void setFactory(EntityManagerFactory factory) {
		this.factory = factory;
	}

	public EntityManager getManager() {
		return manager;
	}

	public void setManager(EntityManager manager) {
		this.manager = manager;
	}
	
}
